#include<stdio.h>
#include<stdlib.h>
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* productExceptSelf(int* nums, int numsSize, int* returnSize) {
    int zero_nums = 0;
    int mul = 1;
    int cout_zero = 0;
    int* answer = (int*)calloc(numsSize, sizeof(int));
    *returnSize = numsSize;
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] == 0)
        {
            zero_nums++;
            cout_zero = i;
        }
        if (nums[i] != 0)
            mul *= nums[i];
    }
    if (zero_nums > 1)
        return answer;
    else if (zero_nums == 1)
    {
        answer[cout_zero] = mul;
        return answer;
    }
    for (int i = 0; i < numsSize; i++)
    {
        answer[i] = mul / nums[i];
    }
    return answer;
}
int main()
{
	int nums[4] = { 1,2,3,4 };
    int size = 0;
    int* returnSize = &size;
    productExceptSelf(nums, 4, returnSize);
	return 0;
}